<template>
  <!-- 访客记录-详情 -->
  <div>
    <public-modal
      width="640px"
      :title="title"
      :footer="true"
      modalStyle="detailModal"
      :publicVisible="publicVisible"
      cancelContext="取消"
      confirmContext="提交"
      @handleOk="handleOk"
      @cancel="cancel"
    >
      <div slot="content">
        <a-textarea v-model="form.content" class="law-textarea" placeholder="请输入" :maxLength="300" :rows="4" />
      </div>
    </public-modal>
  </div>
</template>
<script>
import startEndTime from '@/components/startEndTime'
import publicModal from '@/components/publicModal'
import { getDictItemsFromCache, rentingHouseDetails, webpopulationDetails } from '@/api/api'
import moment from 'moment'
import { getPrefixImg, previewImage } from '@/utils/util'
import { feedbackAdd } from '../../../api/api'

export default {
  name: 'actuallyDetail',
  components: { publicModal, startEndTime },
  props: {
    type: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      publicVisible: false,
      project_company_type: [],
      queryParams: { pageSize: 5 },
      ipagination: { pageSize: 5 },
      disableMixinCreated: true,
      historyInfo: {},
      prefixImg: '',
      form: {
        content: '',
      },
      records: {},
    }
  },
  inject: ['selectedOrg'],
  mounted() {
    this.prefixImg = getPrefixImg()
  },
  computed: {
    title() {
      return this.records.status == 0 ? '问题跟进反馈' : '问题已解决反馈'
    },
  },
  methods: {
    moment,
    async show(records) {
      this.records = records
      this.historyInfo = {
        ...records,
      }
      this.publicVisible = true
    },
    handleOk() {
      const params = {
        ...this.form,
        type: this.records.status == 0 ? 1 : 2,
        id: this.records.id,
      }
      if (!params.content) {
        this.$message.error('请输入反馈内容')
        return
      }
      feedbackAdd(params)
        .then((res) => {
          this.form.content = ''
          this.publicVisible = false
          this.$emit('refresh')
        })
        .finally(() => {})
    },
    cancel(target) {
      this.form.content = ''
      this.publicVisible = false
    },
    handleContractImage(urls) {
      previewImage.call(this, urls)
    },
    handleContract() {
      const { href } = this.$router.resolve({
        path: '/rentingHouse/contract',
        query: {
          contractId: this.historyInfo.id,
          policeAgencyName: this.selectedOrg.policeAgencyName,
        },
      })
      window.open(href)
    },
  },
}
</script>
<style scoped lang="less">
/deep/ .modalCotent {
  padding: 20px 40px;
  border-radius: 0 0 4px 4px;
}

/deep/.law-textarea {
  background: #0746ab;
  border-radius: 4px 4px 4px 4px;
  border: 1px solid #0855cc;
  font-weight: 400;
  font-size: 14px;
  color: #ffffff;
}
</style>
